unit panel1;

interface

uses
  SysUtils, Classes, Controls, ExtCtrls;

type
  tpanel_extra = class(TPanel)
  private
    dblClick:boolean;
    is_zlapane:boolean;
    is_first:boolean;
    orginal_pos:integer;
    delta:Integer;
    pozycja_zaczepienia:integer;
    biezaca_pozyccja:integer;
    max_y:integer;
        { Private declarations }
  protected
    { Protected declarations }
  public
    procedure zlap(max_y_:integer)    ;
    procedure pozycjonuj;
    procedure upusc;
    procedure unies;
    procedure reset;
    procedure setorginal;
    procedure dubleclick;


    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [tpanel_extra]);
end;
procedure tpanel_extra.reset;
begin
  delta:=0;
end;

procedure tpanel_extra.dubleclick;
begin
dblClick:=True;

end;

procedure tpanel_extra.setorginal;
begin
if is_first then
Top:=orginal_pos;
end;

procedure tpanel_extra.pozycjonuj;
begin

if is_first then
begin

if biezaca_pozyccja-delta>max_y then
begin
Top:=max_y;
 exit;
end;
if biezaca_pozyccja-delta<0 then
Top:= 0 else
Top:= biezaca_pozyccja-delta;

end;

end;

procedure   tpanel_extra.upusc;
begin
if is_first then
begin
  is_zlapane:=False;


end;
end;

procedure tpanel_extra.zlap(max_y_:integer);
begin
max_y:=max_y_;
if not is_first then
begin
orginal_pos:=Top;
is_first:=true;
end;
  if dblClick then begin
  dblClick:=false;
  exit;
  end;
if not is_zlapane then
begin
biezaca_pozyccja:=Top;
pozycja_zaczepienia:=Mouse.CursorPos.Y;


is_zlapane:=true;
//if not mpegine.ispause then  mpegine.pause;
end;
end;

procedure tpanel_extra.unies;
begin
  if dblclick then begin
    dblClick:=false;
    exit;
  end;
if is_zlapane then
begin

delta :=(pozycja_zaczepienia - Mouse.CursorPos.Y);
//if not mpegine.ispause then  mpegine.pause;
  pozycjonuj;

end;


end;



end.
